import { useRef, useEffect } from "react";

import init, { draw_mandelbrot } from "../rust-renderer/pkg/rust_renderer";

function App() {
  const canvasRef = useRef<HTMLCanvasElement>(null);

  useEffect(() => {
    const runWasm = async () => {
      await init();
      draw_mandelbrot("fractal-canvas", 800, 600, 100);
    };
    runWasm();
  }, []);

  return (
    <div>
      <canvas
        id="fractal-canvas"
        ref={canvasRef}
        style={{ width: "800px", height: "600px" }}
      />
    </div>
  );
}

export default App;
